<!-- 转工单底部 -->

<template>
  <div>
    <BtnPrimary v-if="one.step > 2" title="上一步" :key="`prev${one.step}`" plain @click="toPrev" />
    <BtnPrimary v-if="one.step < 3" title="下一步" :key="`next${one.step}`" plain @click="toNext" />
    <BtnPrimary v-if="one.step === 3" title="发　布" @click="toAdd" />
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'RepairFooter',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb('add'), CORE.mixWeb('deal', 'deal_')],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 下一步
     */
    async toNext() {
      const { refForm, one } = this
      await refForm.check()
      one.step++
    },

    /**
     * 上一步
     */
    toPrev() {
      const { one } = this
      one.step--
    },

    /**
     * 发布
     */
    async toAdd() {
      const { refForm, one, deal_startEdit } = this
      await refForm.check()
      one.status = one.resolverUserId ? 'task_receive' : 'task_assign'
      one.operate = '工单发布'
      deal_startEdit()
    },
  },
}
</script>
